<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <title>客户管理平台</title>
  <style type="text/css">
    body {
      margin: 0;
    }
  </style>
  <#include "/common/treelib.html">
</head>
<body style="overflow-x:hidden;">
<div
        style="width: 16%; height: 515px; border: 1px solid #e5e5e5; float: left;">
  <ul class="ztree" id="treeMenu"></ul>
</div>
<div style="width: 83%; height: 100%; float: left;">
  <iframe frameborder="0" id="iframepage"
          scrolling="auto" src="" style="width:100%;height:515px;"></iframe>
</div>
</body>
<script type="text/javascript">
    $(function () {
        var treeMenu = $("#treeMenu");
        var treeName = "treeMenu";
        var api = frameElement.api, W = api.opener;
        var TreeManager = {
            /**
             *初始化方法
             */
            init: function () {
                api.button({
                    id: 'cancel',
                    name: '关闭'
                });
                /**
                 * 设置zTree树
                 */
                var setting = {
                    async: {
                        enable: true
                    },
                    data: {
                        simpleData: {
                            enable: true
                        }
                    },
                    callback: {
                        beforeClick: beforeClick,
                        onClick: onClick
                    }
                };

                function beforeClick(treeId, treeNode, clickFlag) {
                    return (treeNode.click != false);
                }

                function onClick(event, treeId, treeNode, clickFlag) {
                    var pId = treeNode.pId;
                    var treeNodeId = treeNode.id;
                    var moduleId = treeNode.moduleId;
                    if (treeNodeId != 99) {//当不是父节点的时候跳转页面
                        document.getElementById("iframepage").style.height = (document.body.scrollHeight - 30) + "px";
                        document.getElementById("iframepage").src = "/systemTableInfo/query?moduleId=" + moduleId;
                    }
                }

                var nodesJson = "${nodesJson!}";
                var zNodes = eval(nodesJson);
                $.fn.zTree.init(treeMenu, setting, zNodes);//初始化树
                document.getElementById("iframepage").style.height = (document.body.scrollHeight - 30) + "px";
            }
        };
        TreeManager.init();
    });
</script>
</html>
